﻿using System;
using System.Diagnostics.Contracts;

namespace OpenLS.Spreadsheet.Formats.Biff.Records
{
    internal class ObjProtectRecord : WorksheetLevelRecord
    {
        internal override BiffRecordType RecordType
        {
            get { return BiffRecordType.ObjProtect; }
        }

        private ushort fLockObj = 1;
        internal override void Apply(BiffReaderWorksheetContext context)
        {
            context.Worksheet.EnsureProtection().Objects = true;
        }

        internal override void WriteContent(BiffWriterWorkbookContext context)
        {
            context.Write(this.fLockObj);
        }

        protected override void ReadContent(BiffReaderContext context, int length)
        {
            fLockObj = context.ReadUInt16();
            Contract.Assert(fLockObj == 1);
        }
    }
}